﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinFormsApp1
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void uiButton1_Click(object sender, EventArgs e)
        {
            string server = uiTextBox1.Text;
            string user = uiTextBox2.Text;
            string password = uiTextBox3.Text;
            string port = uiTextBox4.Text;
            string s_MySQL_Login = string.Format("server={0};user={1};port={2};password={3};", server, user, port, password);

            MessageBox.Show(Mysql.DB_Connection(s_MySQL_Login));
        }

        private void uiButton2_Click(object sender, EventArgs e)
        {
            string server = uiTextBox1.Text;
            string user = uiTextBox2.Text;
            string password = uiTextBox3.Text;
            string port = uiTextBox4.Text;
            string s_MySQL_Login = string.Format("server={0};user={1};port={2};password={3};",server,user,port,password);
            string conn = Mysql.DB_Connection(s_MySQL_Login);
            if (conn == "连接成功")
            {
                Profiles.SetValue("mysql", "server", server);
                Profiles.SetValue("mysql", "user", user);
                Profiles.SetValue("mysql", "database", "work");
                Profiles.SetValue("mysql", "port", port);
                Profiles.SetValue("mysql", "password", password);
                Profiles.SetValue("数据库", "数据库", "mysql");
                MessageBox.Show(conn + "请重新打开程序");
                this.Close();
            }
            else
            {
                MessageBox.Show(conn);
            }
            
          
        }
    }
}
